package com.itheima.test01;

public class Student implements Comparable<Student>{
    private String name;
    private String Chinese;
    private String math;
    private String english;

    public Student() {
    }

    public Student(String name, String chinese, String math, String english) {
        this.name = name;
        Chinese = chinese;
        this.math = math;
        this.english = english;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getChinese() {
        return Chinese;
    }

    public void setChinese(String chinese) {
        Chinese = chinese;
    }

    public String getMath() {
        return math;
    }

    public void setMath(String math) {
        this.math = math;
    }

    public String getEnglish() {
        return english;
    }

    public void setEnglish(String english) {
        this.english = english;
    }
    public Integer Total(){
        return Integer.parseInt(getChinese())+Integer.parseInt(getMath())+Integer.parseInt(getEnglish());
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", Chinese='" + Chinese + '\'' +
                ", math='" + math + '\'' +
                ", english='" + english + '\'' +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        int result = -(this.Total()-o.Total());
       // result = result==0? -(Integer.parseInt(this.getChinese())-Integer.parseInt(o.getChinese())) : result;
        //result = result==0? -(Integer.parseInt(this.getMath())-Integer.parseInt(o.getMath())) : result;
        result = result==0? -(Integer.parseInt(this.getEnglish())-Integer.parseInt(o.getEnglish())) : result;
        return result;
    }
}
